package resources
{
	import slices.TimeSlice;
	import loaders.GroupLoader;
	
	public class LoadResource extends TimeSlice
	{
		public var rs:Array = new Array;
//		public var loader:GroupLoader = new GroupLoader(); 
		
		public function LoadResource()
		{
			super();
		}
		
		public function add(type:IResourceType):void {
			rs.push(type);
		}
		
		override public function onStart():void {
			var loader:GroupLoader = new GroupLoader();
			for each (var type:IResourceType in rs) {
				type.load(loader);
			}
			loader.start(onLoad, null);
		}
		
		private function onLoad(loader:GroupLoader):void {
			for each (var type:IResourceType in rs) {
				type.onLoad(loader);
			}
			isDone = true;
		}
	}
}